package com.platform.qujia.controller;

import com.platform.qujia.pojo.SysUserPosConfig;
import com.platform.qujia.service.ISysUserPosConfigService;
import com.platform.qujia.utils.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @date 2024/2/1
 */
@CrossOrigin
@RestController
@RequestMapping("/userPosConfig")
@Api(tags = "用户pos机配置")
public class SysUserPosConfigController {

    @Autowired
    private ISysUserPosConfigService sysUserPosConfigService;

    @GetMapping("get")
    @ApiOperation("根据userId查询")
    public ResultData<SysUserPosConfig> getByUserId(@RequestParam Long userId){
        return ResultData.success(sysUserPosConfigService.getByUserId(userId));
    }

    @PostMapping("save")
    @ApiOperation("保存")
    public ResultData save(@RequestBody @Validated SysUserPosConfig posConfig){
        sysUserPosConfigService.saveOrUpdate(posConfig);
        return ResultData.success();
    }

}
